package com.chris.seata_order.service;

import com.chris.seata_order.dao.OrderDAO;
import com.chris.seata_order.entity.OrderPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * @author wujf
 * @date 2022/1/19
 */
@Service
public class OrderService {

    @Autowired
    private OrderDAO orderDAO;

    @Transactional(rollbackFor = Exception.class)
    public boolean insertOrder() {
         OrderPO orderPO = new OrderPO();
        // orderPO.setId(1L);
        orderPO.setUserId(111111L);
        orderPO.setProductId(1L);
        orderPO.setCount(1);
        orderPO.setMoney(new BigDecimal("120"));
        int i = 1 / 0;
        int insert = orderDAO.insertSelective(orderPO);
        return insert>0;
    }

}
